package com.fpx.order.plat.bussiness.plat.wish.task;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.fpx.order.plat.bussiness.dao.log.IPullOrderLogDao;
import com.fpx.order.plat.bussiness.entity.CustomerShop;
import com.fpx.order.plat.bussiness.plat.base.PlatOrderCurrentJob;
import com.fpx.order.plat.bussiness.plat.wish.service.WishDeliveryOrderHandler;
import com.fpx.order.plat.bussiness.system.PlatConstants;

@Component
public class WishDeliveryOrderJob extends PlatOrderCurrentJob{

	private final static Logger LOGGER = Logger.getLogger(WishDeliveryOrderJob.class);
	
	@Autowired
	private WishDeliveryOrderHandler wishDeliveryOrderHandler;
	
	@Autowired
	private IPullOrderLogDao pullOrderLogDao;
	/**
	 * 定时任务
	 */
	public void exec(){
		LOGGER.info("【Wish】 自动平台订单开始");
		initMeodth(PlatConstants.ORDER_SOURCE_WISH);
		List<CustomerShop> customerLst=super.getCustomers();
		if(!org.springframework.util.StringUtils.isEmpty(customerLst)){
				// 遍历商家和店铺
		 for (CustomerShop customer : customerLst) {
			 String cm_id=customer.getCm_id();
			 String cs_id=customer.getCs_id();
		       try{
		    	   wishDeliveryOrderHandler.deliveryOrder(customer,0);
		       }catch (Exception ex) {
		    	   LOGGER.error("【WISH】---商家:["+cm_id+"]-商铺ID:["+cs_id+"]-【异常信息】: "+ex.getMessage());
		   }
		  } 
	 }
      LOGGER.info("【Wish】 自动平台订单结束");
	}
}
